<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Save object to file</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="compersisthelper.loadfromstream.html">« COMPersistHelper::LoadFromStream</a></li>
      <li style="float: right;"><a href="compersisthelper.savetostream.html">COMPersistHelper::SaveToStream »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.compersisthelper.html">COMPersistHelper</a></li>
    <li>Save object to file</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="compersisthelper.savetofile" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">COMPersistHelper::SaveToFile</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">COMPersistHelper::SaveToFile</span> &mdash; <span class="dc-title">Save object to file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-compersisthelper.savetofile-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>COMPersistHelper::SaveToFile</strong></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$remember</code><span class="initializer"> = <strong><code>true</code></strong></span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Saves a copy of the object to the specified file.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-compersisthelper.savetofile-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">filename</code></dt>

    <dd>

     <span class="simpara">
      The name of the file to which to save the object.
     </span>
    </dd>

   
   
    <dt>
<code class="parameter">remember</code></dt>

    <dd>

     <span class="simpara">
      Indicates whether the <code class="parameter">filename</code> parameter is to be used as the current
      working file. If <strong><code>true</code></strong>, <code class="parameter">filename</code> becomes the current file and the
      object is supposed to clear its dirty flag after the save. If <strong><code>false</code></strong>, this save operation is
      a &quot;Save A Copy As ...&quot; operation. In this case, the current file is unchanged and the object
      is not supposed to clear its dirty flag.
     </span>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-compersisthelper.savetofile-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-compersisthelper.savetofile-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   A <span class="classname"><a href="class.com-exception.html" class="classname">com_exception</a></span> is thrown if the associated object does not
   implement the <abbr>COM</abbr> interface <span class="interfacename"><strong class="interfacename">IPersistFile</strong></span>,
   or when calling the <span class="methodname"><strong>IPersistFile::Save()</strong></span> method failed.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-compersisthelper.savetofile-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="compersisthelper.savetofile.example.basic">
   <p><strong>示例 #1 Basic <span class="methodname"><strong>COMPersistHelper::saveToFile()</strong></span> Usage</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$word&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">'Word.Application'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$doc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$word</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Documents</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Add</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$ph&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COMPersistHelper</span><span style="color: #007700">(</span><span style="color: #0000BB">$doc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ph</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">SaveToFile</span><span style="color: #007700">(</span><span style="color: #DD0000">'C:\\Users\\cmb\\Documents\\my.docx'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$word</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Quit</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


</div></div></div></body></html>